
// import oimo.dynamics.rigidbody.RigidBody;
// import oimo.dynamics.rigidbody.*;

import { Joint } from "./Joint";
import { RigidBody } from "../../rigidbody/RigidBody";

/**
 * A joint link is used to build a constraint graph for clustering rigid bodies.
 * In a constraint graph, rigid bodies are nodes and constraints are edges.
 * See also `ContactLink`.
 */
export class JointLink {
	_prev: JointLink;
	_next: JointLink;
	_joint: Joint;
	_other: RigidBody;


	constructor(joint: Joint) {
		this._joint = joint;
	}

	/**
	 * Returns the contact the rigid body is attached to.
	 */
	public getContact(): Joint {
		return this._joint;
	}

	/**
	 * Returns the other rigid body attached to the constraint. This provides a quick access
	 * from a rigid body to the other one attached to the constraint.
	 */
	public getOther(): RigidBody {
		return this._other;
	}

	/**
	 * Returns the previous joint link in the rigid body.
	 *
	 * If the previous one does not exist, `null` will be returned.
	 */
	public getPrev(): JointLink {
		return this._prev;
	}

	/**
	 * Returns the next joint link in the rigid body.
	 *
	 * If the previous one does not exist, `null` will be returned.
	 */
	public getNext(): JointLink {
		return this._next;
	}

}
